quartz: Add availability check for >= 10.7 API
authorJesse van den Kieboom <jessevdk@gmail.com>
Sat, 23 Aug 2014 08:59:29 +0000 (10:59 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 29 Sep 2014 19:25:06 +0000 (15:25 -0400)
This adds both a compile time check for the SDK version being
compiled against, as well as a runtime check in the case the
resulting binary is run against an older SDK.

https://bugzilla.gnome.org/show_bug.cgi?id=735054

gtk/gtkapplication-quartz-menu.c

index f21127e17c7ef347b2ad1e54a1f453167d5853e1..a9b3b406cf916eadf8519be28ae92d307ce59baa 100644 (file)
@@ -249,7 +249,7 @@ icon_loaded (GObject      *object,
 
       GtkIconTheme *theme;
       GtkIconInfo *info;
-      gint scale;
+      gint scale = 1;
 
       if (!parsed)
         {
@@ -262,7 +262,14 @@ icon_loaded (GObject      *object,
         }
 
       theme = gtk_icon_theme_get_default ();
-      scale = roundf ([[NSScreen mainScreen] backingScaleFactor]);
+
+#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+       /* we need a run-time check for the backingScaleFactor selector because we
+        * may be compiling on a 10.7 framework, but targeting a 10.6 one
+        */
+      if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)])
+        scale = roundf ([[NSScreen mainScreen] backingScaleFactor]);
+#endif
       info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, icon, ICON_SIZE, scale, GTK_ICON_LOOKUP_USE_BUILTIN);
 
       if (info != NULL)